<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试默认深夜模式</title>
    <!-- 引入 Element UI CSS -->
    <link rel="stylesheet" href="../lib/theme-chalk/index.css">
    <style>
        body {
            margin: 0;
            padding: 20px;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        }
        
        .test-container {
            max-width: 1200px;
            margin: 0 auto;
        }
        
        .header {
            text-align: center;
            margin-bottom: 30px;
            padding: 20px;
            border-radius: 8px;
            background-color: var(--el-color-white, #1a1a1a);
            border: 1px solid var(--el-border-color-base, #404040);
        }
        
        .status {
            margin: 20px 0;
            padding: 15px;
            border-radius: 6px;
            background-color: var(--el-color-primary-light-9, #2a2a2a);
            border-left: 4px solid var(--el-color-primary, #409EFF);
        }
        
        .demo-section {
            margin: 30px 0;
            padding: 20px;
            border-radius: 8px;
            background-color: var(--el-color-white, #1a1a1a);
            border: 1px solid var(--el-border-color-base, #404040);
        }
        
        .demo-section h3 {
            margin-top: 0;
            color: var(--el-color-text-primary, #ffffff);
        }
        
        .controls {
            display: flex;
            gap: 10px;
            margin: 20px 0;
            flex-wrap: wrap;
        }
        
        .info-box {
            background-color: var(--el-color-info-light-9, #2a2a2a);
            border: 1px solid var(--el-color-info-light-7, #404040);
            padding: 15px;
            border-radius: 6px;
            margin: 20px 0;
        }
        
        .info-box h4 {
            margin-top: 0;
            color: var(--el-color-text-primary, #ffffff);
        }
        
        .info-box p {
            color: var(--el-color-text-regular, #e0e0e0);
            margin: 5px 0;
        }
        
        /* 下拉菜单悬停效果 */
        .el-dropdown-menu__item:hover {
            background-color: var(--el-color-primary-light-9, #404040) !important;
            color: var(--el-color-primary, #409EFF) !important;
        }
        
        /* 弹框遮罩 */
        .el-dialog__wrapper {
            backdrop-filter: blur(2px);
        }
        
        /* 消息和通知动画 */
        .el-message, .el-notification {
            animation: slideIn 0.3s ease-out;
        }
        
        @keyframes slideIn {
            from {
                opacity: 0;
                transform: translateY(-20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
    </style>
</head>
<body>
    <div class="test-container">
        <!-- 页面头部 -->
        <div class="header">
            <h1>🌙 测试默认深夜模式</h1>
            <p>此页面用于验证项目是否默认启用深夜模式</p>
        </div>
        
        <!-- 状态显示 -->
        <div class="status">
            <h3>当前状态</h3>
            <div id="statusInfo">
                <p><strong>深夜模式状态：</strong><span id="darkModeStatus">检测中...</span></p>
                <p><strong>本地存储设置：</strong><span id="storageStatus">检测中...</span></p>
                <p><strong>页面加载时间：</strong><span id="loadTime">检测中...</span></p>
            </div>
        </div>
        
        <!-- 控制按钮 -->
        <div class="demo-section">
            <h3>控制面板</h3>
            <div class="controls">
                <button id="toggleBtn" class="el-button el-button--primary">
                    <span id="toggleText">切换模式</span>
                </button>
                <button id="enableBtn" class="el-button el-button--success">启用深夜模式</button>
                <button id="disableBtn" class="el-button el-button--warning">禁用深夜模式</button>
                <button id="clearStorageBtn" class="el-button el-button--info">清除存储设置</button>
                <button id="refreshBtn" class="el-button">刷新页面</button>
            </div>
        </div>
        
        <!-- 组件演示 -->
        <div class="demo-section">
            <h3>组件演示</h3>
            
            <!-- 按钮演示 -->
            <div style="margin-bottom: 20px;">
                <h4>按钮组件</h4>
                <div class="controls">
                    <button class="el-button">默认按钮</button>
                    <button class="el-button el-button--primary">主要按钮</button>
                    <button class="el-button el-button--success">成功按钮</button>
                    <button class="el-button el-button--warning">警告按钮</button>
                    <button class="el-button el-button--danger">危险按钮</button>
                </div>
            </div>
            
            <!-- 输入框演示 -->
            <div style="margin-bottom: 20px;">
                <h4>输入框组件</h4>
                <div style="display: flex; gap: 10px; flex-wrap: wrap;">
                    <input type="text" class="el-input__inner" placeholder="请输入内容" style="width: 200px;">
                    <input type="text" class="el-input__inner" placeholder="禁用状态" disabled style="width: 200px;">
                </div>
            </div>
            
            <!-- 表格演示 -->
            <div style="margin-bottom: 20px;">
                <h4>表格组件</h4>
                <table class="el-table" style="width: 100%; border-collapse: collapse;">
                    <thead>
                        <tr>
                            <th style="padding: 12px; text-align: left; border-bottom: 1px solid var(--el-border-color-base, #404040);">姓名</th>
                            <th style="padding: 12px; text-align: left; border-bottom: 1px solid var(--el-border-color-base, #404040);">年龄</th>
                            <th style="padding: 12px; text-align: left; border-bottom: 1px solid var(--el-border-color-base, #404040);">地址</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td style="padding: 12px; border-bottom: 1px solid var(--el-border-color-base, #404040);">张三</td>
                            <td style="padding: 12px; border-bottom: 1px solid var(--el-border-color-base, #404040);">25</td>
                            <td style="padding: 12px; border-bottom: 1px solid var(--el-border-color-base, #404040);">北京市朝阳区</td>
                        </tr>
                        <tr>
                            <td style="padding: 12px; border-bottom: 1px solid var(--el-border-color-base, #404040);">李四</td>
                            <td style="padding: 12px; border-bottom: 1px solid var(--el-border-color-base, #404040);">30</td>
                            <td style="padding: 12px; border-bottom: 1px solid var(--el-border-color-base, #404040);">上海市浦东新区</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            
            <!-- 卡片演示 -->
            <div style="margin-bottom: 20px;">
                <h4>卡片组件</h4>
                <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px;">
                    <div class="el-card" style="border: 1px solid var(--el-border-color-base, #404040); border-radius: 6px; padding: 20px;">
                        <div class="el-card__header" style="border-bottom: 1px solid var(--el-border-color-base, #404040); padding-bottom: 10px; margin-bottom: 15px;">
                            <h4 style="margin: 0; color: var(--el-color-text-primary, #ffffff);">卡片标题</h4>
                        </div>
                        <div class="el-card__body">
                            <p style="color: var(--el-color-text-regular, #e0e0e0); margin: 0;">这是一个卡片组件的内容区域，用于展示信息。</p>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 下拉菜单演示 -->
            <div style="margin-bottom: 20px;">
                <h4>下拉菜单组件</h4>
                <div class="controls">
                    <div class="el-dropdown" id="dropdownDemo">
                        <button class="el-button el-button--primary" id="dropdownBtn">
                            下拉菜单 <span class="el-dropdown__caret-button">▼</span>
                        </button>
                        <div class="el-dropdown-menu" id="dropdownMenu" style="display: none; position: absolute; background: var(--el-color-white, #2a2a2a); border: 1px solid var(--el-border-color-base, #404040); border-radius: 4px; padding: 5px 0; min-width: 120px; z-index: 1000;">
                            <div class="el-dropdown-menu__item" style="padding: 8px 16px; cursor: pointer; color: var(--el-color-text-primary, #ffffff);" data-value="option1">选项一</div>
                            <div class="el-dropdown-menu__item" style="padding: 8px 16px; cursor: pointer; color: var(--el-color-text-primary, #ffffff);" data-value="option2">选项二</div>
                            <div class="el-dropdown-menu__item" style="padding: 8px 16px; cursor: pointer; color: var(--el-color-text-primary, #ffffff);" data-value="option3">选项三</div>
                            <div class="el-dropdown-menu__item" style="padding: 8px 16px; cursor: pointer; color: var(--el-color-text-primary, #ffffff); border-top: 1px solid var(--el-border-color-base, #404040);" data-value="option4">选项四</div>
                        </div>
                    </div>
                    <span id="dropdownResult" style="margin-left: 10px; color: var(--el-color-text-regular, #e0e0e0);">未选择</span>
                </div>
            </div>
            
            <!-- 弹框演示 -->
            <div style="margin-bottom: 20px;">
                <h4>弹框组件</h4>
                <div class="controls">
                    <button id="dialogBtn" class="el-button el-button--primary">打开弹框</button>
                    <button id="messageBtn" class="el-button el-button--success">显示消息</button>
                    <button id="notificationBtn" class="el-button el-button--warning">显示通知</button>
                </div>
                
                <!-- 弹框 -->
                <div id="dialogDemo" class="el-dialog__wrapper" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); z-index: 2000;">
                    <div class="el-dialog" style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--el-color-white, #2a2a2a); border-radius: 6px; min-width: 400px; max-width: 90%;">
                        <div class="el-dialog__header" style="padding: 20px 20px 10px; border-bottom: 1px solid var(--el-border-color-base, #404040);">
                            <span class="el-dialog__title" style="color: var(--el-color-text-primary, #ffffff); font-size: 16px; font-weight: 600;">弹框标题</span>
                            <button class="el-dialog__headerbtn" id="closeDialogBtn" style="position: absolute; top: 20px; right: 20px; background: none; border: none; font-size: 16px; cursor: pointer; color: var(--el-color-text-regular, #e0e0e0);">×</button>
                        </div>
                        <div class="el-dialog__body" style="padding: 20px; color: var(--el-color-text-regular, #e0e0e0);">
                            <p>这是一个弹框组件的内容区域。在深夜模式下，弹框背景、边框和文字都会自动适配深色主题。</p>
                            <p>您可以在这里放置任何内容，包括表单、列表、图片等。</p>
                        </div>
                        <div class="el-dialog__footer" style="padding: 10px 20px 20px; text-align: right; border-top: 1px solid var(--el-border-color-base, #404040);">
                            <button class="el-button" id="cancelDialogBtn">取消</button>
                            <button class="el-button el-button--primary" id="confirmDialogBtn">确定</button>
                        </div>
                    </div>
                </div>
                
                <!-- 消息提示 -->
                <div id="messageDemo" class="el-message" style="display: none; position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: var(--el-color-white, #2a2a2a); border: 1px solid var(--el-border-color-base, #404040); border-radius: 4px; padding: 15px 20px; color: var(--el-color-text-primary, #ffffff); z-index: 3000; box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.3);">
                    <span>这是一条消息提示</span>
                    <button id="closeMessageBtn" style="margin-left: 10px; background: none; border: none; color: var(--el-color-text-regular, #e0e0e0); cursor: pointer;">×</button>
                </div>
                
                <!-- 通知 -->
                <div id="notificationDemo" class="el-notification" style="display: none; position: fixed; top: 20px; right: 20px; background: var(--el-color-white, #2a2a2a); border: 1px solid var(--el-border-color-base, #404040); border-radius: 4px; padding: 20px; color: var(--el-color-text-primary, #ffffff); z-index: 3000; box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.3); min-width: 300px;">
                    <div style="display: flex; align-items: flex-start;">
                        <div style="flex: 1;">
                            <h4 style="margin: 0 0 10px 0; color: var(--el-color-text-primary, #ffffff);">通知标题</h4>
                            <p style="margin: 0; color: var(--el-color-text-regular, #e0e0e0);">这是一条通知消息，用于向用户展示重要信息。</p>
                        </div>
                        <button id="closeNotificationBtn" style="margin-left: 10px; background: none; border: none; color: var(--el-color-text-regular, #e0e0e0); cursor: pointer; font-size: 16px;">×</button>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 信息说明 -->
        <div class="info-box">
            <h4>测试说明</h4>
            <p><strong>预期行为：</strong></p>
            <ul style="color: var(--el-color-text-regular, #e0e0e0);">
                <li>页面加载时应该自动启用深夜模式</li>
                <li>所有组件应该显示深夜模式的样式</li>
                <li>状态显示应该显示"已启用"</li>
                <li>本地存储应该显示"true"或"未设置"</li>
            </ul>
            <p><strong>测试步骤：</strong></p>
            <ol style="color: var(--el-color-text-regular, #e0e0e0);">
                <li>刷新页面，观察是否自动启用深夜模式</li>
                <li>点击"清除存储设置"按钮</li>
                <li>刷新页面，验证是否仍然默认启用深夜模式</li>
                <li>测试切换功能是否正常工作</li>
            </ol>
        </div>
    </div>

    <script>
        // 页面加载时间
        const loadTime = new Date().toLocaleString('zh-CN');
        document.getElementById('loadTime').textContent = loadTime;
        
        // 检查深夜模式状态
        function checkDarkModeStatus() {
            const isDarkMode = document.body.classList.contains('dark-mode');
            const storageKey = 'element-ui-dark-mode';
            let storageValue = '未设置';
            
            try {
                const stored = localStorage.getItem(storageKey);
                if (stored !== null) {
                    storageValue = stored;
                }
            } catch (error) {
                storageValue = '读取失败';
            }
            
            document.getElementById('darkModeStatus').textContent = isDarkMode ? '已启用' : '已禁用';
            document.getElementById('storageStatus').textContent = storageValue;
            
            // 更新按钮文本
            const toggleText = document.getElementById('toggleText');
            toggleText.textContent = isDarkMode ? '切换到浅色模式' : '切换到深夜模式';
        }
        
        // 切换深夜模式
        function toggleDarkMode() {
            const isDarkMode = document.body.classList.contains('dark-mode');
            if (isDarkMode) {
                document.body.classList.remove('dark-mode');
                localStorage.setItem('element-ui-dark-mode', 'false');
            } else {
                document.body.classList.add('dark-mode');
                localStorage.setItem('element-ui-dark-mode', 'true');
            }
            checkDarkModeStatus();
        }
        
        // 启用深夜模式
        function enableDarkMode() {
            document.body.classList.add('dark-mode');
            localStorage.setItem('element-ui-dark-mode', 'true');
            checkDarkModeStatus();
        }
        
        // 禁用深夜模式
        function disableDarkMode() {
            document.body.classList.remove('dark-mode');
            localStorage.setItem('element-ui-dark-mode', 'false');
            checkDarkModeStatus();
        }
        
        // 清除存储设置
        function clearStorage() {
            localStorage.removeItem('element-ui-dark-mode');
            checkDarkModeStatus();
            alert('已清除本地存储设置，刷新页面后将使用默认设置');
        }
        
        // 刷新页面
        function refreshPage() {
            location.reload();
        }
        
        // 绑定事件
        document.getElementById('toggleBtn').addEventListener('click', toggleDarkMode);
        document.getElementById('enableBtn').addEventListener('click', enableDarkMode);
        document.getElementById('disableBtn').addEventListener('click', disableDarkMode);
        document.getElementById('clearStorageBtn').addEventListener('click', clearStorage);
        document.getElementById('refreshBtn').addEventListener('click', refreshPage);
        
        // 下拉菜单功能
        const dropdownBtn = document.getElementById('dropdownBtn');
        const dropdownMenu = document.getElementById('dropdownMenu');
        const dropdownResult = document.getElementById('dropdownResult');
        let dropdownVisible = false;
        
        dropdownBtn.addEventListener('click', function(e) {
            e.stopPropagation();
            dropdownVisible = !dropdownVisible;
            dropdownMenu.style.display = dropdownVisible ? 'block' : 'none';
            
            // 设置下拉菜单位置
            if (dropdownVisible) {
                const rect = dropdownBtn.getBoundingClientRect();
                dropdownMenu.style.top = (rect.bottom + 5) + 'px';
                dropdownMenu.style.left = rect.left + 'px';
            }
        });
        
        // 下拉菜单项点击事件
        dropdownMenu.addEventListener('click', function(e) {
            if (e.target.classList.contains('el-dropdown-menu__item')) {
                const value = e.target.getAttribute('data-value');
                const text = e.target.textContent;
                dropdownResult.textContent = `已选择: ${text}`;
                dropdownVisible = false;
                dropdownMenu.style.display = 'none';
            }
        });
        
        // 点击其他地方关闭下拉菜单
        document.addEventListener('click', function() {
            if (dropdownVisible) {
                dropdownVisible = false;
                dropdownMenu.style.display = 'none';
            }
        });
        
        // 弹框功能
        const dialogBtn = document.getElementById('dialogBtn');
        const dialogDemo = document.getElementById('dialogDemo');
        const closeDialogBtn = document.getElementById('closeDialogBtn');
        const cancelDialogBtn = document.getElementById('cancelDialogBtn');
        const confirmDialogBtn = document.getElementById('confirmDialogBtn');
        
        dialogBtn.addEventListener('click', function() {
            dialogDemo.style.display = 'block';
        });
        
        function closeDialog() {
            dialogDemo.style.display = 'none';
        }
        
        closeDialogBtn.addEventListener('click', closeDialog);
        cancelDialogBtn.addEventListener('click', closeDialog);
        confirmDialogBtn.addEventListener('click', function() {
            alert('您点击了确定按钮');
            closeDialog();
        });
        
        // 点击遮罩关闭弹框
        dialogDemo.addEventListener('click', function(e) {
            if (e.target === dialogDemo) {
                closeDialog();
            }
        });
        
        // 消息提示功能
        const messageBtn = document.getElementById('messageBtn');
        const messageDemo = document.getElementById('messageDemo');
        const closeMessageBtn = document.getElementById('closeMessageBtn');
        
        messageBtn.addEventListener('click', function() {
            messageDemo.style.display = 'block';
            setTimeout(function() {
                messageDemo.style.display = 'none';
            }, 3000);
        });
        
        closeMessageBtn.addEventListener('click', function() {
            messageDemo.style.display = 'none';
        });
        
        // 通知功能
        const notificationBtn = document.getElementById('notificationBtn');
        const notificationDemo = document.getElementById('notificationDemo');
        const closeNotificationBtn = document.getElementById('closeNotificationBtn');
        
        notificationBtn.addEventListener('click', function() {
            notificationDemo.style.display = 'block';
            setTimeout(function() {
                notificationDemo.style.display = 'none';
            }, 5000);
        });
        
        closeNotificationBtn.addEventListener('click', function() {
            notificationDemo.style.display = 'none';
        });
        
        // 页面加载完成后检查状态
        document.addEventListener('DOMContentLoaded', function() {
            // 延迟一点检查，确保所有脚本都加载完成
            setTimeout(checkDarkModeStatus, 100);
        });
        
        // 监听页面可见性变化
        document.addEventListener('visibilitychange', function() {
            if (document.visibilityState === 'visible') {
                checkDarkModeStatus();
            }
        });
    </script>
</body>
</html> 